home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
hity wydania
/
trueSpace 7.6
/
tS761B8Std.exe
/
{app}
/
Scripts
/
D3D
/
RsD3DPointRender.fx
< prev
next >
Wrap
Text File
|
2008-06-10
|
5KB
|
182 lines
//----------------------------------------------------------------------
//Point-rendering
//
//Author - Michal Valient
//Copyright (C) 2004-2008 Caligari corporation
//
//----------------------------------------------------------------------
uniform float4x4 mToClip;
uniform float4 cColorMultiplier;
uniform float4 cColorModifier;
uniform float fSizeMultiplier;
uniform float fSizeModifier;
uniform float fOpacity;
#ifdef RsShaderHWSKINNING
#define SKIN_INDEX_SHIFT 0.001960784313725490196078431372549f
#define RTD3DMESH_MAXIMUM_BONE_COUNT 64
float4x3 RsD3DMaterialFromME_mSkinMatrices[RTD3DMESH_MAXIMUM_BONE_COUNT];
#endif //RsShaderHWSKINNING
//Depth bias is now configurable inside code
uniform float fDepthBias = 1.0f / 65536.0f; //Set depth bias to the value that will work for 16bit z-buffers
struct VS_MATPOINT_IN {
float4 vPosition : POSITION; //position in object space
float4 cPointColor : COLOR; //point color
float fPointSize : PSIZE; //point size
};
typedef struct {
float4 vPosition : POSITION; //position in object space
float4 cPointColor : COLOR; //point color
float fPointSize : PSIZE; //point size
} VS_MATPOINT_OUT;
VS_MATPOINT_OUT VS_CMaterialPointRender( in VS_MATPOINT_IN input
#ifdef RsShaderHWSKINNING
, in float4 D3_vInputBlendIndices : BLENDINDICES
, in float4 D3_cInputBlendWeight : BLENDWEIGHT
#endif //RsShaderHWSKINNING
)
{
float4 local_vertex_position;
#ifdef RsShaderHWSKINNING
float3 tmp_position = 0;
//Get the blend weights
float4 blend_weights = (255.0f/127.0f)*D3_cInputBlendWeight - (128.0f / 127.0f);
float4 blend_indices = D3_vInputBlendIndices * 255.0f + SKIN_INDEX_SHIFT;
/// Skin it!
for (int bone_idx = 0; bone_idx<4; bone_idx++)
{
int matrix_idx = (int)blend_indices[bone_idx];
float weight = blend_weights[bone_idx];
float3 bone_position = weight*mul(input.vPosition, RsD3DMaterialFromME_mSkinMatrices[matrix_idx]);
tmp_position += bone_position;
}
local_vertex_position.xyz = tmp_position.xyz;
local_vertex_position.w = 1.0f;
#else
local_vertex_position = input.vPosition;
#endif //RsShaderHWSKINNING
VS_MATPOINT_OUT output;
output.vPosition = mul(local_vertex_position, mToClip); //vertex clip position
output.vPosition.z = ((output.vPosition.z/output.vPosition.w) - fDepthBias) * output.vPosition.w;
output.cPointColor = cColorMultiplier * input.cPointColor + cColorModifier;
output.cPointColor.a = fOpacity * input.cPointColor.a;
output.fPointSize = fSizeMultiplier * input.fPointSize + fSizeModifier;
return output;
}
float4 PS_CMaterialPointRender(float4 cPointColor : COLOR) : COLOR
{
return cPointColor;
}
vertexshader VS_PointRenderer = compile vs_2_0 VS_CMaterialPointRender();
pixelshader PS_PointRenderer = compile ps_1_1 PS_CMaterialPointRender();
///Point rendering for PS capable hardware
technique T_PointRender_PS
{
pass P0
{
VertexShader = (VS_PointRenderer);
PixelShader = (PS_PointRenderer);
AlphaBlendEnable = true;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = false;
SpecularEnable = false;
ColorVertex = true;
PointScaleEnable = false;
CullMode = NONE;
}
}
technique T_PointRender_Cascade
{
pass P0
{
VertexShader = (VS_PointRenderer);
PixelShader = NULL;
AlphaBlendEnable = true;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = false;
Lighting = false;
ShadeMode = FLAT;
SpecularEnable = false;
ColorVertex = true;
// Set the stages.
ColorOp[0] = SELECTARG1;
ColorArg1[0] = DIFFUSE;
ColorOp[1] = DISABLE;
AlphaOp[0] = SELECTARG1;
AlphaArg1[0] = DIFFUSE;
AlphaOp[1] = DISABLE;
PointScaleEnable = false;
CullMode = NONE;
}
}
technique T_PointRender_Plain
{
pass P0
{
VertexShader = (VS_PointRenderer);
PixelShader = NULL;
AlphaBlendEnable = true;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = false;
Lighting = false;
ShadeMode = FLAT;
SpecularEnable = false;
ColorVertex = true;
PointScaleEnable = false;
CullMode = NONE;
}
}